
<html>
<head>
    <meta charset="utf-8">
    <style>
        html,body{
            margin: 0;
        }
        input{
            margin: 20px;
            width: 300px;
        }
    </style>
</head>
<body>
<input id="input" type="text"  placeholder="http://b.zero.com:8080/b.html">
<script>


    var input = document.querySelector('#input');
    // 监听 message 事件
    window.addEventListener('message',function (ev) {
        input.value = ev.data;
        console.log('b.html received message = ' + ev.data);
    })

    // 监听当前页面的 input 事件，postMessagge 给 a.html
    input.addEventListener('input',function () {
        window.parent.postMessage(this.value, '*');
    })

</script>
</body>
</html>